#include <QFile>
#include <QTextStream>
#include "usersetting.h"

const static char SETTING_FILE[] = "userSetting.dat";

UserSetting::UserSetting()
{
}

void UserSetting::setUserName(const QString &userName)
{
    mUserName = userName;
    save();
}

QString UserSetting::getUserName()
{
    load();
    return mUserName;
}

void UserSetting::load()
{
    QFile file(SETTING_FILE);
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream in(&file);
    in >> mUserName;
    file.close();
}

void UserSetting::save()
{
    QFile file(SETTING_FILE);
    file.open(QIODevice::WriteOnly | QIODevice::Text);
    QTextStream out(&file);
    out << mUserName;
    file.close();
}
